package com.siyuanren.gcocp.service;

import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.siyuanren.gcocp.entity.WxUser;
import com.siyuanren.gcocp.entity.WxUserCourse;
import com.siyuanren.gcocp.entity.WxUserOrder;
import com.siyuanren.gcocp.vo.CreateOrderVO;
import com.siyuanren.gcocp.vo.FreeCourseOrderVO;

/**
 * Created by   anxing
 * Project_name gcocp-parent
 * Path         com.siyuanren.gcocp.service
 * Date         2018/6/8
 * Time         15:20
 * Description
 */
public interface OrderService {
    /**
     * 返回课程的购买信息
     * @param userId
     * @param courseId
     * @return 如果购买过,返回购买课程,如果没有购买过,返回null
     */
    WxUserOrder getBuyedCourse(Integer userId, Integer courseId);

    /**
     * 插入订单
      * @param order
     * @return
     */
    int insert(WxUserOrder order);

    /**
     * 更新订单
     * @param orderId
     * @param order
     * @return
     */
    int update(Integer orderId, WxUserOrder order);

    /**
     * 处理订单状态
     * @param result
     */
    void completeOrder(WxPayOrderNotifyResult result) throws Exception;

    /**
     * 创建订单
     * @param vo
     * @return
     */
    WxPayMpOrderResult createOrder(CreateOrderVO vo);

    /**
     * 免费课程,直接加入. 不需要微信支付
     * @param vo
     * @return
     */
    void freeCourseOrder(FreeCourseOrderVO vo) throws Exception;
}
